/* include/kernel/task.h 
 * 
 * Copyright (C) 2021, 2022 intirain. 
 *
 * This file is part of evx. 
 * 
 * evx is free software: you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation, either version 3 of the License, or 
 * (at your option) any later version. 
 * 
 * evx is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
 * GNU General Public License for more details. 
 * 
 * You should have received a copy of the GNU General Public License 
 * along with evx. If not, see <https://www.gnu.org/licenses/>
 */ 




#ifndef __TASK_H
#define __TASK_H


#ifndef __ASSEMBLER__

#include <sys/types.h>
#include <arch/arch_task.h>


/* exit()'ed, but not be wait()'ed by its parent */
#define TASK_ZOMB 		0
/* it's ready to run but not running */
#define TASK_READY 		1
/* running on current cpu, and the current points to the struct task of it */
#define TASK_RUNNING 		2
/* waiting for some resources */
#define TASK_WAIT 		3

struct task {
	int 			state;
	int 			pid;

	struct task 		*parent;

	/* other things such as pgid or sid are strange for me, well, 
	 * support them later */

	/* for x86, it includes sp, ptable etc */
	struct arch_task_descr 	arch_descr;
	int 			nice;
};

extern struct task 		*current;
extern struct task 		init_task;

/* returns a new task copied from current */
struct task *dup_task(void);

#endif
#endif

